package com.sky.controller.admin;

import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
@Slf4j

public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;
    /**
     *  设置店铺状态
     * @param status
     * @return
     */
    @PutMapping("/status/{status}")
    @ApiOperation("设置店铺状态")
    public  Result setStatus (@PathVariable  Integer status) {
        log.info("设置店铺状态");
        // 保存店铺状态信息
        redisTemplate.opsForValue().set("shop_status",status);
        System.out.println(redisTemplate.opsForValue());
        return Result.success();
    }

    /**
     * 获取店铺状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public Result<Integer> getStatus(){
        log.info("获取店铺状态");
        Integer status = (Integer) redisTemplate.opsForValue().get("shop_status");
        return Result.success(status);
    }
}
